<link rel="stylesheet" href="{$osslink}static/index/css/layui.css?{$version}"/>
<link rel="stylesheet" href="{$osslink}static/index/css/index.css?{$version}"/>
<link rel="stylesheet" href="{$osslink}static/index/css/user.css?{$version}"/>
<link rel="stylesheet" href="{$osslink}static/index/css/task.css?{$version}"/>
<link rel="stylesheet" href="{$osslink}static/index/css/artical.css?{$version}"/>
<link rel="stylesheet" href="{$osslink}static/index/css/font-awesome.min.css?{$version}"/>
<title>{$seo['meta_title']}</title>
<meta name="keywords" content="{$seo['meta_keyword']}"></meta>
<meta name="description" content="{$seo['meta_description']}"></meta>
<script src="{$osslink}static/index/js/jquery-3.6.0.min.js?{$version}"></script>
<script src="{$osslink}static/index/js/jquery.cookie.js?{$version}"></script>
<script src="{$osslink}static/index/js/layui.js?{$version}"></script>
<script src="{$osslink}static/index/js/wangEditor.min.js?{$version}"></script>
<script>var uuid = localStorage.getItem("uuid");var token = localStorage.getItem(uuid);
levelObj = {'1':'<i style="margin-left:2px" class="fa fa-wheelchair-alt" aria-hidden="true"></i>',
    '2':'<i style="margin-left:2px" class="fa fa-bicycle" aria-hidden="true"></i>',
    '3':'<i style="margin-left:2px" class="fa fa-car" aria-hidden="true"></i>',
    '4':'<i style="margin-left:2px" class="fa fa-train" aria-hidden="true"></i>',
    '5':'<i style="margin-left:2px" class="fa fa-rocket" aria-hidden="true"></i>'}</script>
<script>
     token = token=="null"?"":token;
    var chrome_lang= $.cookie("think_lang");
    var langs = localStorage.getItem("langs");
    if(langs != '' && langs != null && langs != undefined && chrome_lang != langs){
        $.cookie("think_lang",langs);
        window.location.reload();
    }
    var search = window.location.search;
    if(search.indexOf("lang=") != -1){
        var start = window.location.search.substr(window.location.search.indexOf("lang="));
        var end = start.indexOf("&");
        if(end != -1){
            show_language = start.substr(5,end);
        } else {
            show_language = start.substr(5);
        }
        if(show_language != chrome_lang){
            localStorage.setItem("langs",show_language);
            $.cookie("think_lang",show_language);
            changeLang(show_language);
        }

    }
    
    function createpage(dom,total,limit,action)
    {
        layui.use('laypage', function(){
            var laypage = layui.laypage;
            laypage.render({
                elem: dom
                ,limit:limit
                ,count: total
                ,prev:'{:__("上一页")}'
                ,next:'{:__("下一页")}'
                ,jump:action
            });
        });
    }
    $.ajaxSetup({
        beforeSend:function(){
            var _this = $(this);
            var langs = localStorage.getItem("langs");
            if(langs == '' || langs == undefined || langs == null){
                langs = ''
            }
            if(_this[0].url.indexOf("?") == -1){
                _this[0].url = _this[0].url+'?lang='+langs;
            } else {
                _this[0].url = _this[0].url+'&lang='+langs;
            }
            
        },
        dataType:'json',
        dataFilter:function(data,type){
            datacopy = JSON.parse(data);
            if(datacopy.code == 401){
                layer.msg("{:__('登陆时间过长已失效请重新登陆')}",{icon:3},function(){
                    removelocal();
                    window.location.reload();
                });
            }
            return data;
        },error:function(e){
            layer.msg('{:__("网络异常")}',{icon:2});
            console.log(e);
        }
    });
    
    function removelocal()
    {
        for(i in localStorage){
            if(i == 'langs'){
                continue;
            }
            localStorage.removeItem(i);
        }
    }
    function getLocalStorage(key)
    {
        var lang = $.cookie("think_lang");
        var jsondata = localStorage.getItem(lang+"_"+key);
        return jsondata;
    }
    function setLocalStorage(key,item)
    {
        var lang = $.cookie("think_lang");
        localStorage.setItem(lang+"_"+key,item);
    }
    function CacheLoad(objs)
    {
        var missionsurl = "/api/mission/getOptions";
        var infourl = "/api/info/getOptions";
        var userurl = "/api/user/profile";
        var config = {
            'mission_category':missionsurl,
            'mission_status':missionsurl,
            'intergralzone':missionsurl,
            'timezone':missionsurl,
            'category_list':missionsurl,
            'mission_hall_status':missionsurl,
            'mission_config':missionsurl,
            'info_category':infourl,
            'category_list':infourl,
            'langset':missionsurl,
            'userData':userurl
        }
        var mission = '';
        var info = '';
        var user = '';
        for(i in objs){
            if(i == 'token'){
                uuid = 'u'+parseInt(Math.random()*10000000000)+Date.now()+''+Date.now();
                token = objs['token'];
                localStorage.setItem("uuid",uuid);
                localStorage.setItem(uuid,token);
            }
            if(config[i] == missionsurl){
                mission += i+',';
            }
            if(config[i] == infourl){
                info += i+',';
            }
            if(config[i] == userurl){
                user += i+',';
            }
        }
        if(mission == '' && info == '' && user == ''){

            $(document).queue('cache',function(){
                $.ajax({
                    url:missionsurl,
                    type:'post',
                    data:{params:'mission_category,mission_status,intergralzone,timezone,category_list,mission_hall_status,mission_config,langset'},
                    success:function(ret){
                        var code = ret['code'];
                        if(code == 1){
                            if(ret['data'] == '' || ret['data'] == null || ret['data'] == undefined){
                                return false;
                            }
                            var data = ret['data'];
                            for(i in data){
                                var item = JSON.stringify(data[i]);
                                setLocalStorage(i,item);
                            }
                            if($(document).queue("cache").length == 0){
                                $(document).dequeue('outcache');
                            }
                            $(document).dequeue('cache');
                        } else if(ret['code'] != 401) {
                            layer.msg("{:__('缓存加载失败')}",{icon:2});
                            return false;
                        }
                    }
                });
            })
            $(document).queue('cache',function(){
                $.ajax({
                    url:infourl,
                    type:'post',
                    data:{params:'info_category,category_list'},
                    success:function(ret){
                        var code = ret['code'];
                        if(code == 1){
                            if(ret['data'] == '' || ret['data'] == null || ret['data'] == undefined){
                                return false;
                            }
                            var data = ret['data'];
                            for(i in data){
                                var item = JSON.stringify(data[i]);
                                setLocalStorage(i,item);
                            }
                            if($(document).queue("cache").length == 0){
                                $(document).dequeue('outcache');
                            }
                            $(document).dequeue('cache');
                        } else if(ret['code'] != 401) {
                            layer.msg("{:__('缓存加载失败')}",{icon:2});
                            return false;
                        }
                    }
                });
            });
            if(token != '' && token != undefined && token != null){
                $(document).queue('cache',function(){
                    $.ajax({
                        url:userurl,
                        type:'post',
                        data:{token:token},
                        success:function(ret){
                            var code = ret['code'];
                            if(code == 1){
                                if(ret['data'] == '' || ret['data'] == null || ret['data'] == undefined){
                                    return false;
                                }
                                if(ret['data']['userData'] == '' || ret['data']['userData'] == null || ret['data']['userData'] == undefined){
                                    return false;
                                }
                                if(ret['data']['userData']['authens'][1] != undefined){
                                    ret['data']['userData']['emailauth'] = 1;
                                } else {
                                    ret['data']['userData']['emailauth'] = 0;
                                }
                                if(ret['data']['userData']['authens'][2] != undefined){
                                    ret['data']['userData']['cardauth'] = 1;
                                } else {
                                    ret['data']['userData']['cardauth'] = 0;
                                }
                                var userData = JSON.stringify(ret['data']['userData']);
                                setLocalStorage('userData',userData);
                                if($(document).queue("cache").length == 0){
                                    $(document).dequeue('outcache');
                                }
                                $(document).dequeue('cache');
                            } else if(ret['code'] != 401) {
                                layer.msg("{:__('缓存加载失败')}",{icon:2});
                                return false;
                            }
                        }
                    });
                });
            }
            if($(document).queue("cache").length == 0){
                $(document).dequeue("outcache");
            }
            $(document).dequeue('cache');
        } else {
            if(mission != ''){
                $(document).queue("cache",function(){
                    $.ajax({
                        url:missionsurl,
                        type:'post',
                        data:{params:mission},
                        success:function(ret){
                            var code = ret['code'];
                            if(code == 1){
                                if(ret['data'] == '' || ret['data'] == null || ret['data'] == undefined){
                                    return false;
                                }
                                var data = ret['data'];
                                for(i in data){
                                    var item = JSON.stringify(data[i]);
                                    setLocalStorage(i,item);
                                }
                                // if($(document).queue("cache").length == 0){
                                    $(document).dequeue(mission);
                                // }
                                $(document).dequeue('cache');
                            } else if(ret['code'] != 401) {
                                layer.msg("{:__('缓存加载失败')}",{icon:2});
                                return false;
                            }
                        }
                    });
                });
                
            }
            if(info != ''){
                $(document).queue("cache",function(){
                    $.ajax({
                        url:infourl,
                        type:'post',
                        data:{params:info},
                        success:function(ret){

                            var code = ret['code'];
                            if(code == 1){
                                if(ret['data'] == '' || ret['data'] == null || ret['data'] == undefined){
                                    return false;
                                }
                                var data = ret['data'];
                                for(i in data){
                                    var item = JSON.stringify(data[i]);
                                    setLocalStorage(i,item);
                                }
                                // if($(document).queue("cache").length == 0){
                                    $(document).dequeue(info);
                                // }
                                $(document).dequeue('cache');
                            } else if(ret['code'] != 401) {
                                layer.msg("{:__('缓存加载失败')}",{icon:2});
                                return false;
                            }
                        }
                    });
                });
            }
            if(user != ''){
                $(document).queue("cache",function(){
                    if(token == ''){
                        if($(document).queue("cache").length == 0){
                            $(document).dequeue("outcache");
                        }
                        return false;
                    }
                    $.ajax({
                        url:userurl,
                        type:'post',
                        data:{token:token},
                        success:function(ret){
                            var code = ret['code'];
                            if(code == 1){
                                if(ret['data'] == '' || ret['data'] == null || ret['data'] == undefined){
                                    return false;
                                }
                                if(ret['data']['userData'] == '' || ret['data']['userData'] == null || ret['data']['userData'] == undefined){
                                    return false;
                                }
                                if(ret['data']['userData']['authens'][1] != undefined){
                                    ret['data']['userData']['emailauth'] = 1;
                                } else {
                                    ret['data']['userData']['emailauth'] = 0;
                                }
                                if(ret['data']['userData']['authens'][2] != undefined){
                                    ret['data']['userData']['cardauth'] = 1;
                                } else {
                                    ret['data']['userData']['cardauth'] = 0;
                                }
                                var userData = JSON.stringify(ret['data']['userData']);
                                
                                setLocalStorage('userData',userData);
                                // if($(document).queue("cache").length == 0){
                                    $(document).dequeue('user');
                                // }
                                $(document).dequeue('cache');
                            } else if(ret['code'] != 401) {
                                layer.msg("{:__('缓存加载失败')}",{icon:2});
                                return false;
                            }
                        }
                    });
                });
            }
            // if($(document).queue("cache").length == 0){
                // $(document).dequeue("outcache");
            // }
            $(document).dequeue("cache");

        }

    }
    function emailCheck(email){
        var reg = 
        new RegExp(/(\S)+@qq.com|(\S)+@gmail.com|(\S)+@163.com|(\S)+@126.com|(\S)+@189.com|(\S)+@139.com|(\S)+@163.net|(\S)+@88.com|(\S)+@sohu.com|(\S)+@263.net|(\S)+@sina.com|(\S)+@sina.cn|(\S)+@outlook.com|(\S)+@aol.com|(\S)+@yahoo.com|(\S)+@icloud.com|(\S)+@mail.com|(\S)+@inbox.com/);
        if(!reg.test(email)){
            return false;
        }
        return true;
    }
    function telCheck(tel){
        var reg = new RegExp(/(\d)+/);
        if(!reg.test(tel)){
            return false;
        }
        return true;
    }
    function EamilCodeCheck(code)
    {
        var reg = new RegExp(/\d{4}/);
        if(!reg.test(code)){
            return false;
        }
        return true;
    }
    function noLog(){
       
        if(token == '' || token == null || token == undefined){
            layer.msg("{:__('未登录/登陆已过期,请重新登陆')}",{icon:3},function(){
                window.location.href = '/index/Index/login';
            });
        }
    }
    function changeimg(_this)
    {
         
    }
    function changeLang(lang)
    {
        var objs = {};
        CacheLoad(objs);
        $.cookie("think_lang",lang);
        self.location.reload();
    }
    function keyLimit(e,num,_this){
        var key_code = e.keyCode;
        if(key_code<48 && key_code != 8){
            return false;
        }
        if(key_code>57 && key_code<96){
            return false;
        }
        if(key_code>105){
            return false;
        }
        if(num!=0){
            var len = _this.val().length;
            if(len>=num && key_code != 8){
                return false;
            }
        }
        return true;
    }
    function imgLoaing(url,data){
        $.getJSON({
            url:url,
            data:data,
            type:"post",
            dataFilter:function(data,type){
                return data;
            },
            error:function(e){
                var _this = $(this);
                var avatar = _this[0].url;
                var data = _this[0].data;
                var start = parseInt(data.indexOf("="))+1;
                var id = data.substr(start);
                $('#user_'+id).attr('src',avatar);
            }
        });
    }
    function getDate(time){
        if(time == ""){
            var date = new Date();
        } else {
            time = parseInt(time)*1000;
            var date = new Date(time);
        }
        var year = date.getFullYear();
        var month = parseInt(date.getMonth());
        month = month+1;
        if(month<10){
            month = '0'+month;
        }
        var day = parseInt(date.getDate());
        if(day<10){
            day = '0'+day;
        }
        var hour = parseInt(date.getHours());
        if(hour<10){
            hour = '0'+hour;
        }
        var min = parseInt(date.getMinutes());
        if(min<10){
            min = '0'+min;
        }
        var sec = parseInt(date.getSeconds());
        if(sec<10){
            sec = '0'+sec;
        }
        var create_time = year+'-'+month+'-'+day+" "+hour+":"+min+":"+sec;
        return create_time;
    }
</script>